package com.hns.can.service.web;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hns.can.common.domain.GridPage;
import com.hns.can.common.service.CommonInitParamService;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.can.common.web.BaseController;
import com.hns.can.service.service.LineShiftInfoService;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.util.ResponseUtil;
import com.hns.tool.pub.PubUtil;

/**
 * 线路偏移controller
 * @author:zhangyu
 * @email:zhangyu2222z@sina.cn
 * @version Revision 2.0.0
 */
@Controller
@RequestMapping("lineShiftInfo")
public class LineShiftInfoController extends BaseController {
	/**
	 * 线路偏移service
	 */
	@Autowired
	private LineShiftInfoService lineShiftInfoService;
	
	/**
	 * 初始化参数service
	 */
	@Autowired
    private CommonInitParamService commonInitParamService;
	
	/**
	 * 获取线路偏移统计列表
	 * @param params
	 * @return
	 * @throws Exception
	 * @author:zhangyu
	 * @email:zhangyu2222z@sina.cn
	 */
	@RequestMapping("getLineShiftStatisList")
	@ResponseBody
	public Object getLineShiftStatisList(CommonParamsVo params) throws Exception{
		//commonInitParamService.initParamsLimitLine(params, this.getCurrentUser().getUser(), Arrays.asList(""));
		commonInitParamService.initParamsLimitCar(params, this.getCurrentUser().getUser(), Arrays.asList(""));
        Pagination page = lineShiftInfoService.getLineShiftStatisList(params);
        GridPage grid = new GridPage(page);
		return this.getReturnResult(grid);
	}
	
	/**
	 * 获取线路偏移明细列表
	 * @param params
	 * @return
	 * @throws Exception
	 * @author:zhangyu
	 * @email:zhangyu2222z@sina.cn
	 */
	@RequestMapping("/getDeviationDetail")
	@ResponseBody
    public Object getDeviationDetail(CommonParamsVo params,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		commonInitParamService.initParamsLimitCar(params, this.getCurrentUser().getUser(), Arrays.asList(""));
//		if(PubUtil.isNotEmpty(params.getCarIds())){
//		}else if(PubUtil.isNotEmpty(params.getLineIds())){
//			commonInitParamService.initParamsLimitLine(params, this.getCurrentUser().getUser(), Arrays.asList(""));
//		}
        Pagination page = lineShiftInfoService.getPageLineDeviation(params);
        GridPage grid = new GridPage(page);
        return this.getReturnResult(grid);
    }
	
}

